﻿<%@ Page Title="" Language="C#" MasterPageFile="../Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<SailHero.Soft.FrameWork.Models.SYS_DEPARTMENT>>" %>
<%@ Import Namespace="SailHero.Soft.FrameWork.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    部门管理
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        //Gridview CheckBox全选
        $(function () {
            $("#chkAll").click(function () {
                var flag = $(this).attr("checked");
                if (flag == "checked") {
                    $("[name=CheckBoxSelect]:checkbox").each(function () {
                        $(this).attr("checked", flag);
                    });
                }
                else {
                    $("[name=CheckBoxSelect]:checkbox").each(function () {
                        $(this).attr("checked", false);
                    });

                }
            });

            $("[name=CheckBoxSelect]").click(function () {
                $("#chkAll").attr("checked", false);
            });

            $("#edit").click(function () {
                var obj = $("[name=CheckBoxSelect]:checked");
                if (obj.length == 0) {
                    $.messager.alert("提示信息", "请选择编辑项！", "info");
                }
                else if (obj.size() > 1) {
                    $.messager.alert("提示信息", "一次只能编辑一项！", "info");
                }
                else {
                    obj.each(function () {
                        var value = $(this).val();
                        location.href = "/Dept/Edit/?id=" + value;
                    });
                }
            });

            $("#delete").click(function () {

                var obj = $("[name=CheckBoxSelect]:checked");
                if (obj.length == 0) {
                    $.messager.alert("提示信息", "请选择删除项！", "info");
                }
                else if (obj.size() > 1) {
                    $.messager.alert("提示信息", "一次只能删除一项！", "info");
                }
                else {
                    var select = "";
                    obj.each(function () {
                        select = $(this).val();
                    });
                    $.messager.confirm("提示信息", "确定要删除选中项？", function (r) {
                        if (r) {
                            var url = "/Dept/Delete";
                            $.post(url, {
                                deptID: select
                            },
                function (data) {
                    if (data == "success") {
                        window.location.href = "/Dept/Index";
                    }
                    else {
                        $.messager.alert("错误信息", data, "error");
                    }
                });
                        }
                    });
                }
            });
        });
    </script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="TabTitle" runat="server">
    部门管理
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <table border="0" cellpadding="0" cellspacing="0" style="width: 100%;">
        <tr>
            <td>
                <table style="width: 100%; margin-top: 5px;" cellpadding="0" cellspacing="0">
                    <caption class="tcaption">
                        <table style="width: 100%;" cellpadding="0" cellspacing="0" border="0">
                            <tr>
                                <td align="left">
                                    <table class="tableTitle">
                                        <tr>
                                            <td width="80px">
                                                <span style="color: Green; font-weight: bold; padding-left: 5px;">部门列表</span>
                                            </td>
                                            <td width="50px">
                                                <a href="/Dept/Create" class="operateA">"
                                                    <img style="vertical-align: middle; border: 0;" src="<%=Page.ResolveUrl("../../content/images/add.png")%>"
                                                        alt="新增" />&nbsp;新增</a>
                                            </td>
                                            <td width="50px">
                                                <a id="edit">
                                                    <img style="vertical-align: middle" src="<%=Page.ResolveUrl("../../content/images/edit2.png")%>"  alt="修改" />&nbsp;编辑</a>
                                            </td>
                                            <td width="50px">
                                                <a id="delete">
                                                    <img style="vertical-align: middle" src="<%=Page.ResolveUrl("../../content/images/delete.png")%>" alt="删除" />&nbsp;删除</a>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                        </table>
                    </caption>
                    <tr>
                        <td>
                            <table class="mytable" cellspacing="0" border="1" style="width: 100%; border-collapse: collapse;">
                                <tr>
                                    <th>
                                        NO.
                                    </th>
                                    <th>
                                        <input id="chkAll" type="checkbox" />
                                    </th>
                                    <th>
                                        部门名称
                                    </th>
                                    <th>
                                        部门经理
                                    </th>
                                    <th>
                                        上级部门
                                    </th>
                                    <th>
                                        排序号
                                    </th>
                                    <th>
                                        电话
                                    </th>
                                    <th>
                                        传真
                                    </th>
                                    <th>
                                        状态
                                    </th>
                                </tr>
                                <%int num = 0; //编号
                               

                               
                                 
                                 foreach (var item in Model)
                                 {
                                     num += 1; %>
                                <tr>
                                    <td align="center" style="width: 30px;">
                                        <%=num %>
                                    </td>
                                    <td align="center" style="width: 30px;">
                                      <input id="CheckBoxSelect" name="CheckBoxSelect" value="<%: item.DEPTID %>" type="checkbox" />
                                    </td>
                                    <td align="center" style="width: 10%;">
                                       <%= item.DEPTCNAME %>
                                    </td>
                                    <td align="center">
                                       
                                    </td>
                                    <td align="center">
                                        
                                    </td>
                                    <td align="center">
                                       <%=item.ORDERNUM %>
                                    </td>
                                    <td align="center">
                                        <%= item.TELEPHONE %>
                                    </td>
                                    <td align="center">
                                       <%=item.FAX %>
                                    </td>
                                    <td align="center">
                                        <%if (item.ISENABLE=="1")
                                          { %>
                                        可用
                                        <%}
                                          else
                                          {%>
                                        <font color="red">禁用</font>
                                        <%} %>
                                    </td>
                                </tr>
                                <%} %>
                            </table>
                        </td>
                    </tr>
                    <tr>
                       <td class="page2">
                         <%=ViewData["page"] %>
                     </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</asp:Content>
